<?php
//user验证其
namespace app\api\validate;

//TP验证模块
use think\Validate;

class Project extends Validate
{
   
    //定义验证规则
    protected $rule = [
        'name' =>  'require|length:3,32',
        'introduce' => 'require',
        'brief_introduce' => 'require|length:6,256',
        'image' => 'length:0,256|url',
    
        'area' => 'require',
        'show_state' => 'require'
    ];
    
    //定义错误信息
    protected $message = [
        'username.require' => '项目名不得为空',
        'username.length' => '项目名长度不在3-32范围之内',

        'introduce' => '介绍不得为空',

        'brief_introduce' => '简介不得为空',
        'brief_introduce' => '简介长度不在6-256范围之内',

        'area' => '分区参数不存在',
        'show_state' => '项目状态参数不存在'
    ];

    //验证场景-添加
    protected function sceneProjectAdd()
    {
    	return $this->only(['name', 'brief_introduce', 'area']);
    }

    //验证场景-编辑
    protected function sceneProjectEdit()
    {
    	return $this->only(['name', 'image', 'brief_introduce', 'introduce', 'show_state']);
    }
}
